#include "FloatChromosome.h"

FloatChromosome::FloatChromosome() : VectorChromosome<double>()
{
}

FloatChromosome::FloatChromosome(int size) :
        VectorChromosome<double>(size)
{
}

FloatChromosome::FloatChromosome(const FloatChromosome &other) :
        VectorChromosome<double>(other)
{
}

FloatChromosome& FloatChromosome::operator=(const FloatChromosome& other)
{
    this->VectorChromosome<double>::operator=(other);

    return *this;
}

double FloatChromosome::getRandomValue() const
{
    double temp = (qrand() / (static_cast<double>(RAND_MAX) + 1.0)) *
                  (maxValue - minValue) +
                  minValue;
    return temp;
}

QString FloatChromosome::toString() const
{
    QString out("");

    for(int i=0;i<geneArray.size() - 1;++i)
        out += QString::number(geneArray[i],'g') + ", ";
    out += QString::number(geneArray.last(),'g');

    return out;
}

Chromosome* FloatChromosome::duplicate() const
{
    return new FloatChromosome(*this);
}
